#include <iostream>
#include <cstring>
#define MAX_CHAR 100
using namespace std;

struct Str{
	int aCount;
	int bCount;
	int cCount;
};

int main(){
	char str[MAX_CHAR];
	cin >> str;
	Str table[MAX_CHAR + 1][MAX_CHAR + 1];
	for(int i = 0; i <= MAX_CHAR; i++)
		for(int j = 0; j <= MAX_CHAR; j++)
			table[i][j].aCount = table[i][j].bCount = table[i][j].cCount = 0;
	int n = 0;
	for(int i = 0;; i++){
		if(str[i] == '\0'){
			n = i;
			break;
		}
		if(str[i] == 'a'){
			table[i+1][i+1].aCount++;
			continue;
		}
		if(str[i] == 'b'){
			table[i+1][i+1].bCount++;
			continue;
		}
		if(str[i] == 'c'){
			table[i+1][i+1].cCount++;
			continue;
		}
	}
	for(int length = 2; length <= n; length++){
		for(int i = 1; i <= n - length + 1; i++){
			int j = i + length - 1;
			for(int k = i; k < j; k++){
				table[i][j].aCount = table[i][j].aCount + table[i][k].aCount*table[k+1][j].cCount + table[i][k].bCount * table[k+1][j].cCount + table[i][k].cCount * table[k+1][j].aCount;
				table[i][j].bCount = table[i][j].bCount + table[i][k].aCount*table[k+1][j].aCount + table[i][k].aCount * table[k+1][j].bCount + table[i][k].bCount * table[k+1][j].bCount;
				table[i][j].cCount = table[i][j].cCount + table[i][k].bCount*table[k+1][j].aCount + table[i][k].cCount * table[k+1][j].bCount + table[i][k].cCount * table[k+1][j].cCount;
			}
		}
	}
	cout << table[1][n].aCount << endl;
}
